package com.iuie.ns.frame.utils.httpclients;

import com.iuie.ns.frame.exception.ServiceException;


/**
 * http client工具类
 * @author liujie
 * @date 2018年6月1日下午4:43:48
 */
public class HttpClientUtils {
	
	private HttpClientUtils() {
		
	}
	
	public static HttpResult send(HttpParams params) {
		IHttpRequest req = null;
		
		HttpRequestMethod method = params.method();
		if (method == HttpRequestMethod.GET) {
			req = new HttpGetRequest();
		}
		if (method == HttpRequestMethod.POST) {
			req = new HttpPostRequest();
		}
		if (method == HttpRequestMethod.DELETE) {
			req = new HttpDeleteRequest();
		}
		if (method == HttpRequestMethod.PUT) {
			req = new HttpPutRequest();
		}
		if (req != null) {
			return req.send(params);
		}
		throw new ServiceException("不支持的请求方法，HttpRequestMethod");
	}

}
